Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exit codes of security:certificates commands #37783

Merged
merged 1 commit into from
Aug 9, 2020
Merged

Conversation

phil-davis
Copy link
Contributor

@phil-davis phil-davis commented Aug 7, 2020

Description

I was getting acceptance test fails when running cliMain/securityCertificates.feature against ownCloud10 latest (currently 10.5.0 tarball). The security:certificates:remove and security:certificates:import commands are not exiting with proper error codes when something is wrong, so that makes it impossible for the acceptance test scenarios to react appropriately in steps like Then the command should have been successful - that step never fails because the command status is always 0 = success.

The easiest thing to do is first to fix the bug that was already reported in the related issue.

  1. When importing a certificate and the certificate file is not found, exit with status 1.

  2. When removing a certificate and the certificate does not exist, exit with status 1.

  3. Adjust the acceptance tests to have cases for these.

  4. Adjust .drone.star - it has security:certificates:import commands for when tests are using HTTPS and certificates. Those commands were also being done in pipelines where the certificates did not exist and were not needed. The commands were never successful. Now that the commands exit with an error status, the pipelines were failing during the setup. The starlark code has been adjusted so that it only does security:certificates:import in the correct cases.

Note 1: I did not find any existing unit tests for commands in core/Command/Security. The commands seem to have been introduced in PR #21370 but that PR had no automated tests.

Note 2: I added some simple unit tests

Related Issue

How Has This Been Tested?

Locally running commands:

$ php occ security:certificates:remove xyz.crt
certificate not found
$ echo $?
1
$ php occ security:certificates:import xyz.crt
certificate not found
$ echo $?
1

and scenarios in acceptance tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@phil-davis
Copy link
Contributor Author

Also see issue #37784 which was the trigger for fixing this.

Copy link
Member

@individual-it individual-it left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests look good to me

@codecov
Copy link

codecov bot commented Aug 7, 2020

Codecov Report

Merging #37783 into master will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #37783      +/-   ##
============================================
- Coverage     64.71%   64.70%   -0.01%     
- Complexity    19391    19392       +1     
============================================
  Files          1284     1284              
  Lines         75753    75757       +4     
  Branches       1333     1333              
============================================
  Hits          49021    49021              
- Misses        26340    26344       +4     
  Partials        392      392              
Flag Coverage Δ Complexity Δ
#javascript 54.03% <ø> (ø) 0.00 <ø> (ø)
#phpunit 65.88% <0.00%> (-0.01%) 19392.00 <0.00> (+1.00) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
core/Command/Security/ImportCertificate.php 0.00% <0.00%> (ø) 4.00 <0.00> (ø)
core/Command/Security/RemoveCertificate.php 0.00% <0.00%> (ø) 4.00 <0.00> (+1.00)
lib/private/Security/CertificateManager.php 87.91% <0.00%> (-0.98%) 35.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3aba53...b009417. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 7, 2020

Codecov Report

Merging #37783 into master will decrease coverage by 0.00%.
The diff coverage is 16.66%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #37783      +/-   ##
============================================
- Coverage     64.71%   64.70%   -0.01%     
- Complexity    19391    19392       +1     
============================================
  Files          1284     1284              
  Lines         75753    75757       +4     
  Branches       1333     1333              
============================================
+ Hits          49021    49022       +1     
- Misses        26340    26343       +3     
  Partials        392      392              
Flag Coverage Δ Complexity Δ
#javascript 54.03% <ø> (ø) 0.00 <ø> (ø)
#phpunit 65.88% <16.66%> (-0.01%) 19392.00 <0.00> (+1.00) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
core/Command/Security/ImportCertificate.php 0.00% <0.00%> (ø) 4.00 <0.00> (ø)
core/Command/Security/RemoveCertificate.php 0.00% <0.00%> (ø) 4.00 <0.00> (+1.00)
lib/private/Security/CertificateManager.php 89.01% <100.00%> (+0.12%) 35.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3aba53...b009417. Read the comment docs.

@phil-davis
Copy link
Contributor Author

codecov/project https://codecov.io/gh/owncloud/core/pull/37783/diff

The uncovered code is in the core/Command/Security code, which did not have any unit tests anyway. I have covered it with acceptance test scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

removal of non-existing security certificates by cli doesn't produce error and exit code is still zero
3 participants